package com.qk.management;

import com.qk.common.event.EventPublisher;
import com.qk.common.event.CleanupCompletedEvent;
import com.qk.management.service.listener.CleanupCompletionListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import jakarta.annotation.PostConstruct;

@ServletComponentScan
@SpringBootApplication
@EnableScheduling
@ComponentScan(basePackages = {"com.qk.management", "com.qk.common"})
public class QkManagementApplication {
    private final CleanupCompletionListener cleanupCompletionListener;
    public QkManagementApplication(CleanupCompletionListener cleanupCompletionListener) {
        this.cleanupCompletionListener = cleanupCompletionListener;
    }
    public static void main(String[] args) {
        SpringApplication.run(QkManagementApplication.class, args);
    }
    @PostConstruct
    public void registerEventListeners() {
        EventPublisher.subscribe(CleanupCompletedEvent.class, (com.qk.common.event.EventListener) cleanupCompletionListener);
    }
}